import requests

# 添加部门
resp = requests.post(url="http://ihrm2-test.itheima.net/api/company/department",
                     headers={"Content-Type": "application/json",
                              "Authorization": "e1438c1c-58e0-4efa-adb4-2db920768e43"},
                     json={
                         "name": "ICU123",
                         "code": "13858037125"
                     })
print(resp.json())

# 查询部门
resp = requests.get(url="http://ihrm2-test.itheima.net/api/company/department/:id",
                    headers={"Authorization": "e1438c1c-58e0-4efa-adb4-2db920768e43"})
print(resp.json())

# 修改部门
resp = requests.put(url="http://ihrm2-test.itheima.net/api/company/department/:id",
                    headers={"Content-Type": "application/json",
                             "Authorization": "e1438c1c-58e0-4efa-adb4-2db920768e43"},
                    json={ "name": "ICU123",
                         "code": "13858037125"})
# 将 结果转换为 json，打印
print(resp.json())

# 删除部门
resp = requests.delete(url="http://ihrm2-test.itheima.net//api/company/department/:id",
                       headers={"Authorization": "ad7ebdd8-36ed-4c8d-b987-78097cecc4b4"})
# 将 结果转换为 json，打印
print(resp.json())
